package com.c78.fz.controller;

import com.c78.fz.common.result.Result;
import com.c78.fz.model.entity.History;
import com.c78.fz.service.HistoryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/historys")
public class HistoryController {
    @Resource
    HistoryService historyService;

    @GetMapping("/gethistory")
    public Result list(String waterManName, String sendWaterTime, Integer pageNum, Integer pageSize) {
        return historyService.getHistoryPage(waterManName,sendWaterTime,pageNum,pageSize);
    }

    @PostMapping("/addhistory")
    public Result addHistory(@RequestBody History history){
        return historyService.saveHistory(history);
    }

    @PutMapping("/updhistory")
    public Result updateHistory(@RequestBody History history){
        return historyService.updateHistory(history);
    }

    @GetMapping("/gethistorybyid/{id}")
    public Result getHistoryById(@PathVariable Integer id) {
        return historyService.getHistoryById(id);
    }

    @DeleteMapping("/batchdel/{ids}")
    public Result batchDeleteHistory(@PathVariable List<Integer> ids) {
        return historyService.batchDeleteHistory(ids);
    }
}
